
#'
#' Define an environmental variable
#' 
#' @aliases plot.env print.env
#' 
#' @usage 
#' env(x,y,z)
#' plot(env,type="contour")
#' 
#' 
#' @param x,y the coordinate of the environmental variable measured
#' @param z the corresponding values of the environmental variables 
#' @param env an env object
#' @param type the type of plot, default is 'contour', another option is 'persp'
#' 
#' @export
env=function(x,y,z){
  data=data.frame(x,y,z)
  class(data)=c("env",class(data))
  return(data)
}

#' @export
plot.env=function(env,type="contour"){
  x=sort(unique(env$x))
  y=sort(unique(env$y))
  nx=length(x)
  ny=length(y)
  elevmat5=matrix(env$z,nrow=nx,ncol=ny,byrow=TRUE)
    
  # color contour map and perspective wire-frame plot
  angle=max(env$x)/max(env$y)
  if(type=="contour")
    filled.contour(x=x,y=y,z=elevmat5,asp=,color=terrain.colors)
  else
    persp(x=x,y=y,z=elevmat5,phi=60,theta=20,asp=angle,expand=0.5)
}

print.env=function(env){
  
}